﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>书籍列表</title>
    <link rel="stylesheet" type="text/css" href="/manager/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/manager/easyui/themes/icon.css">
    <script type="text/javascript" src="/manager/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/manager/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript">
	    //工具栏
	    var toolbar = [{
	        text: '修改',
	        iconCls: 'icon-edit',
	        handler: function () {
	            $('#dd').dialog('open');
	            $('#dd').form('load',{
	                bookName:rows.bookName,
	                price:rows.price,
                    groupPrice:rows.groupPrice,
                    bookIntroduce:rows.bookIntroduce,
                    authorIntroduce:rows.authorIntroduce
                })

	        },
	    }, '-', {
	        text: '启用',
	        iconCls: 'icon-ok',
	        handler: function () {
	            console.log(rows);
	            $.ajax({
                    url:'/manager/book/modifyStatus',
                    data:{
                        id:rows.id,
                        flag:1
                    },
                    type:'post',
                    dataType:'json',
                    success:function (rs) {
                        alert(rs.msg);
                        $('#booklist').datagrid('reload');
                    },
                    error:function () {
                        aler("网络错误,请稍后再试");
                    }
                })
            }
	    }, '-', {
	        text: '禁用',
	        iconCls: 'icon-cancel',
	        handler: function () {
	            $.ajax({
                    url:'/manager/book/mdoifyStatus',
                    data:{
                        id:rows.id,
                        flag:2
                    },
                    type:'post',
                    dataType:'json',
                    success:function (rs) {
                        alert(rs.msg);
                        $('#booklist').datagrid('reload');

                    },
                    error:function () {
                        aler("网络错误,请稍后再试")
                    }
                })

            }
	    }];
	   $(function(){
	       $('#booklist').datagrid({
				title:'书籍列表',
				iconCls:'icon-save',
				url:'/manager/book/findAll',
				columns:[
				    [
					{field:'bookname',title:'名称',width:100,align:'center'},
					{field:'author',title:'作者',width:200,align:'center'},
					{field:'price',title:'单价',width:80,align:'center'},
					{field:'iSBN',title:'ISBN',width:200,align:'center'},
					{field:'pressid',title:'出版社',width:200,align:'center',formatter:function (val,row) {
                        if (null!=row.press) {
                            return row.press.name;
                        }
                        }},
	                {field:'supplierid',title:'供货商',width:500,align:'center',formatter:function (val,row) {
                            if (null !=row.supplier){
                                return row.supplier.name
                            }
                        }},
                    {field:'flag',title:'状态',width:100,align:'center',formatter:function (val,row) {
                            switch (row.flag) {
                                case 1:return "启用(已通过审核)";
                                case 2:return "禁用";
                                case 3:return "审核未通过";
                                case 4:return "未通过";
                                default:return "未知状态";
                            }
                        }}
				]
                ],
				toolbar: toolbar,
				pagination: true,//表示在datagrid设置分页
               	pageSize: 5,
				singleSelect:true,
                pageList: [5,10,20],
                onclick:function (val,row,index) {
                    rows=row;
                }
               
			});

		 //初始化查询栏
		 $("#submit_search").linkbutton({ iconCls: 'icon-search', plain: true })
            .click(function () {
                $('#dg').datagrid({ queryParams: form2Json("searchform") });   //点击搜索
            });

          //初始化修改窗口
         $('#dd').dialog({
			    title: 'My Dialog',
			    width: 700,
			    height: 500,
			    closed: true,
			    cache: false,
			    href: '',
			    modal: true,
			    iconCls: 'icon-save',
                buttons: [{
                    text:'提交',
                    iconCls:'icon-ok',
                    handler:function(){
                        alert('ok');
                    }
                },{
                    text:'关闭',
                    handler:function(){
                        alert('cancel');;
                    }
                }]
			});

	   });
	</script>
</head>
<body>
   <form name="searchform" method="post" action="" id ="searchform">
    <td width="70" height="30"><strong>书籍查询：</strong></td>
    <td height="30">
        <input type="text" name="keyword" size=20 placeholder="书籍名称"/>
        <input type="text" name="keyword" size=20 placeholder="ISBN"/>
        <select name="search_type" id="search_type" >
            <option value="-1">请选择出版社</option>
            <option value="be_name" >张大仙出版社</option>
            <option value="be_intro">土大仙出版社</option>
            <option value="be_intro">狗子出版社</option>
        </select>
        <select name="search_type" id="search_type" >
            <option value="-1">请选择供应商</option>
            <option value="be_name" >供应商1</option>
            <option value="be_intro">供应商2</option>
            <option value="be_intro">供应商3</option>
        </select>
        编辑推荐:<input type="checkbox" name="" value=""/>
        本周精选:<input type="checkbox" name="" value=""/>
    </td>
	<td>
	  <a id="submit_search">搜索</a>
	</td>
  </form>
  <table id="booklist"></table>
    <div id="dd">
           <div align="center" style="margin-top: 30px">
            <form id="ff" method="post">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="name" style="width:50%" data-options="label:'书籍名称:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="email" style="width:50%" data-options="label:'单价:',required:true,validType:'email'">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="subject" style="width:50%" data-options="label:'团购价:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="message" style="width:50%;height:60px" data-options="label:'书籍简介:',multiline:true">
            </div>
             <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="message" style="width:50%;height:60px" data-options="label:'作者简介:',multiline:true">
            </div>
             <div style="margin-bottom:20px">
               封面图片:&nbsp;&nbsp;&nbsp;&nbsp; <input  type="file"/>
            </div>
            <div style="margin-bottom:20px">
               编辑推荐:<input type="checkbox" name="" value=""/>
               本周精选:<input type="checkbox" name="" value=""/>
            </div>

        </form>
           </div>
    </div>
</body>
</html>